-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce standalone build size #10668
Reduce standalone build size #10668
Conversation
The size change of |
d378177
to
39b9ace
Compare
packages/babel-core/package.json
Outdated
@@ -3,6 +3,7 @@ | |||
"version": "7.7.2", | |||
"description": "Babel compiler core.", | |||
"main": "lib/index.js", | |||
"_main:used-by-babel-standalone": "src/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this 😆
Is it possible to use webpack's resolve
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using resolve.alias
like the other packages, webpack will ignore the browsers
field in package.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow. If we did something like this, wouldn't it work?
resolve: {
alias: {
"@babel/core$": "packages/babel-core/src/index.js"
}
}
a7d6bf4
to
a27059a
Compare
# Conflicts: # babel.config.js
credits to Nicolò
a27059a
to
1c1119f
Compare
const babelRuntimePackageJSONPath = require.resolve( | ||
"@babel/runtime/package.json" | ||
); | ||
const path = require("path"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a simple question. What is the advantage of declaring within this scope rather than at the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a strong reason: require("path")
is used only when building babel-*-standalone. However, this config is shared with other building process (build/jest), by doing so we could avoid the overhead of requiring a builtin module.
In this PR we build babel-standalone against the
src
version of@babel/*
dependencies instead oflib
, which is specified in theirpackage.json
. By doing so thetransform-runtime
can replace babel helper calls by runtime helper imports. It is impossible to achieve this onlib
version where the helpers are inlined.Here is a brief summary on the number of inlined
function _interopRequireDefault(obj)
declarations in the artifacts. (produced by this script, lower is better)Note that there are still 4 inlined
_interopRequireDefault
declaration not removed in@babel/standalone
, all of which comes from third party dependencies, i.e.regenerator-runtime
.